{extend name="common/base" /}

{block name="style"}
<style>
    body{
        background: #F5F5F5;
        touch-action: none;
    }
</style>
{/block}
{block name="body"}
<div class="jf-mains">
    <div id="pullrefresh" {neq name="user_box_id" value="0"}style="margin-top:0.6rem;"{/neq} class="mui-scroll-wrapper">
        <div class="mui-scroll">
            <div class="jf-top jf-topvs">
                <p class="ye-top-ps" style='padding:0.5rem 0 0.245rem;font-size:0.18rem;'>剩余积分</p>
                <p class="ye-top-ps2" style='font-size:0.3rem;'>{$user_info['score']}</p>
            </div>
            <ul class="jf-nav">
                <a href="{:url('score',['type'=>0])}" >
                    <li {eq name="$type" value="0" } class="active" {/eq} >
                        <span class="jf-span">收入</span>
                    </li>
                </a>
                <a href="{:url('score',['type'=>1])}" >
                    <li {eq name="$type" value="1" } class="active" {/eq} >
                        <span class="jf-span">支出</span>
                    </li>  
                </a>        
            </ul>
            <!-- 收入 -->
            <div>
                <ul class="sr-nav" >
                    {foreach $list as $vo }
                    <li>
                        {switch name="$vo.change_matters"}
                        {case value="1"}
                        <div class="sr-left">
                            <p class="p1">购物赠送<i>（订单号:{$vo['order_info']['order_no']}）</i></p>
                            <p class="p2">{$vo['createtime']}</p>
                        </div>
                        <div class="sr-rig">+{$vo['change_amount']}</div>
                        {/case}

                        {case value="3"}
                        <div class="sr-left">
                            <p class="p1">平台调整<i>（原因:{$vo['remark']}）</i></p>
                            <p class="p2">{$vo['createtime']}</p>
                        </div>
                        {eq name="$vo['change_type']" value="0"}
                        <div class="sr-rig">+{$vo['change_amount']}</div>
                        {else/}
                        <div class="sr-rig sr-rig2">-{$vo['change_amount']}</div>
                        {/eq}
                        {/case}

                        {case value="4"}
                        <div class="sr-left">
                            <p class="p1">购物抵扣<i>（订单号:{$vo['order_info']['order_no']}）</i></p>
                            <p class="p2">{$vo['createtime']}</p>
                        </div>
                        <div class="sr-rig sr-rig2">-{$vo['change_amount']}</div>
                        {/case}

                        {/switch}
                    </li>
                    {/foreach}
                </ul>
            </div>
            <input type='hidden' id='js-type' value="{$type}" >
        </div>
    </div>
</div>
{/block}
{block name="script"}
<script>
    mui('body').on('tap', 'a', function () {
        window.top.location.href = this.href;
    });
    var p = 1;
    var type = $('#js-type').val();
    var loading = false;  //状态标记
    mui.init({
        pullRefresh: {
            container: '#pullrefresh',
            up: {
                height: 50, //可选.默认50.触发上拉加载拖动距离
                contentrefresh: '正在加载...',
                contentnomore: '没有更多了', //可选，请求完毕若没有更多数据时显示的提醒内容；
                callback: pullupRefresh
            }
        }
    });

    /**
     * 上拉加载具体业务实现
     */
    function pullupRefresh() {
        $.post("{:url('scoreItem')}", {p: p, type: type}, function (res) {
            if (res) {
                $(".sr-nav").append(res);
                p++;
                mui('#pullrefresh').pullRefresh().endPullupToRefresh(false); //参数为true代表没有更多数据了。
            } else {
                mui('#pullrefresh').pullRefresh().endPullupToRefresh(true); //参数为true代表没有更多数据了。
            }
        }, 'json');

    }
</script>
{/block}